from typing import List, Optional
from pydantic import BaseModel, Field, ConfigDict
from datetime import datetime

class ArticleBase(BaseModel):
    model_config = ConfigDict(protected_namespaces=())
    title: str
    content: Optional[str] = None
    status: Optional[str] = 'draft'  # 默认为草稿
    template_id: Optional[str] = None
    references: Optional[List[str]] = []
    reference_content: Optional[str] = None
    reference_style: Optional[str] = None
    length: Optional[str] = 'medium'
    style: Optional[str] = 'professional'
    model_id: str = None

class ArticleCreate(ArticleBase):
    pass

class ArticleUpdate(BaseModel):
    title: Optional[str] = None
    content: Optional[str] = None
    status: Optional[str] = None
    template_id: Optional[str] = None
    references: Optional[List[str]] = None
    reference_content: Optional[str] = None
    reference_style: Optional[str] = None
    length: Optional[str] = None
    style: Optional[str] = None

class ArticleResponse(ArticleBase):
    id: str
    created_at: datetime
    updated_at: datetime
    user_id: Optional[str] = None
    summary: Optional[str] = None
    view_count: Optional[int] = 0

class PaginatedArticles(BaseModel):
    items: List[ArticleResponse]
    total: int
    page: int
    limit: int 